package lekcja4.zad5;

public class Cukierek {
    private String smak;
    private double waga;

    public Cukierek(String smak, double waga) {
        this.smak = smak;
        this.waga = waga;
    }

    public boolean equals(Cukierek cukierek) {
        if (this.smak.equals(cukierek.smak) && this.waga == cukierek.waga) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Cukierek cukierek = (Cukierek) o;

        if (Double.compare(cukierek.waga, waga) != 0) return false;
        if (!smak.equals(cukierek.smak)) return false;

        return true;
    }

   /* @Override
    public int hashCode() {
        int result;
        long temp;
        result = smak.hashCode();
        temp = Double.doubleToLongBits(waga);
        result = 31 * result + (int) (temp ^ (temp >>> 32));
        return result;
    }*/

    @Override
    public String toString() {
        return "Cukierek{" +
                "smak='" + smak + '\'' +
                ", waga=" + waga +
                '}';
    }
}
